<template>
    <div>
        <div>
            <button @click="b = !b">是否显示组件</button>
        </div>
        <template v-if="b">
            <AppItem :count="count">
                <button @click="addCount">count++</button>
            </AppItem>
        </template>
    </div>
</template>

<script>
import AppItem from './components/AppItem.vue';

export default {
    components: { AppItem },
    data() {
        return {
            b: false,
            count: 0
        }
    },
    methods: {
        addCount() {
            this.count++;
        }
    }
}
</script>

<style scoped></style>